<template>
  <div>
		<div class="css-img" v-if="payState == 'success'">
			<img class="css-okimg" src="@/assets/images/meal/payok.png"  />
		</div>
		<div class="css-img" v-if="payState == 'fail'">
			<img class="css-okimg" src="@/assets/images/meal/payfail.png"  />
		</div>		
    <p class="css-content">{{ payState == 'success' ? '支付成功' : '支付失败'}}</p>
		<div class="flex-center pt-50">
			<van-button class="solid-btn  flex-g-1 mlr-30 br-40" v-if="payState == 'success'" @click="goOrder">查看订单</van-button>
			<van-button class="solid-btn flex-g-1 mlr-30 br-40" v-if="payState == 'fail'" @click="goPay">继续支付</van-button>
		</div>
		<div class="flex-center pt-50">
			<van-button class=" bg-tp bd-solid flex-g-1 mlr-30 br-40"  @click="goHome">返回首页</van-button>
		</div>
  </div>
</template>

<script>
import headPortraitBox from 'components/headPortraitBox'
import { GetCashierDetailBySn } from 'api/order'
import { GoldplanJs } from 'utils/url.js'
export default {
  components: {
    headPortraitBox
  },
  props: {
  },
  data() {
    return {
			payState:'',
      orderInfo: {},
      Sn: ''
    }
  },
  computed: {

  },
  watch: {

  },
  created() {
		this.payState = this.$route.params.payState
		console.log('payState',this.payState)
    //const _this = this
    //const _query = _this.$route.query
    //console.log(_query)
    //if (_query && _query.out_trade_no) {
    //  _this.Sn = _query.out_trade_no
    //  _this.GetCashierDetailBySn()
    //  if (document.referrer.indexOf('https://payapp.weixin.qq.com/') !== -1) {
    //  // 加载点石成金js-sdk(页面没有该sdk则加载)
    //    const jsList = document.getElementsByTagName('script')
    //    if (jsList && jsList.length) {
    //      let hasGoldplanJs = false
    //      for (var i = 0; i < jsList.length; i++) {
    //        console.log(jsList[i].src)
    //        if (jsList[i].src && jsList[i].src === GoldplanJs) {
    //          hasGoldplanJs = true
    //          break
    //        }
    //      }
    //      if (!hasGoldplanJs) {
    //        _this.$utils.loadScript(GoldplanJs)
    //      }
    //    }
    //  }
    //} else {
    //  _this.$toast.fail('订单号有误')
    //}
  },
  mounted() {
    //parent.postMessage(JSON.stringify({
    //  action: 'onIframeReady',
    //  displayStyle: 'SHOW_CUSTOM_PAGE',
    //  height: 850
    //}), 'https://payapp.weixin.qq.com')
  },
  activated() {},
  methods: {
		goOrder(){
			this.$router.push(`/mealAllOrder`)
		},
		goPay(){

		},
		goHome(){
			this.$router.push(`/orderMeal/222`)
		},
    GetCashierDetailBySn() {
      const _this = this
      GetCashierDetailBySn(_this.Sn).then(res => {
        if (res) {
          var _data = res.Data
          if (_data.Sn) {
            _data.Sn = _data.Sn.substr(_data.Sn.length - 4)
          }
          _this.orderInfo = _data
        }
      })
    },
    openUserCard() {
      console.log(this.$LocalDomain)
      const url = this.$LocalDomain + '/m/home/union?pm=123&storeId=' + this.orderInfo.StoreId
      console.log(document.referrer)
      if (document.referrer.indexOf('https://payapp.weixin.qq.com/') !== -1) {
        parent.postMessage(JSON.stringify({
          action: 'jumpOut',
          jumpOutUrl: url
        }), 'https://payapp.weixin.qq.com')
      } else {
        window.location.href = url
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.css-img{
		margin-top: 120px;
		display: flex;
    justify-content: center;
}
.css-okimg{
	width: 140px;
		height: 140px;
}
.css-content{
		text-align: center;
		color: #333333;
		font-size: 34px;
		height: 48px;
		line-height: 48px;
		margin-top: 30px;
		margin-bottom: 60px;
}
</style>
